From 122a5ba73e50bfc6c474fcee0d352aa7fab9f05d Mon Sep 17 00:00:00 2001 From: Richard Yu Date: Mon, 1 Sep 2025 22:43:16 +0800 Subject: [PATCH] luci-mod-network: diagnostics: add realtime command output The diagnostics page is using `fs.exec()` to execute command, which blocks until command exit. Users have to wait for a while to see the result. When doing IPv6 traceroute, this may cause XHR timeout, if target host is unreachable. (See issue #7210) This commit uses new `responseProgress` callback and `stderr` option added in luci.js and fs.js to update command output. Signed-off-by: Richard Yu Link: https://github.com/openwrt/luci/pull/7920 --- .../luci-static/resources/view/network/diagnostics.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js index 1bfa95501a..fa8ae2f64d 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js @@ -8,15 +8,16 @@ return view.extend({ handleCommand: function(exec, args) { - var buttons = document.querySelectorAll('.diag-action > .cbi-button'); + var buttons = document.querySelectorAll('.diag-action > .cbi-button'), + out = document.querySelector('textarea'); for (var i = 0; i < buttons.length; i++) buttons[i].setAttribute('disabled', 'true'); - return fs.exec(exec, args).then(function(res) { - var out = document.querySelector('textarea'); - - dom.content(out, [ res.stdout || '', res.stderr || '' ]); + return fs.exec_direct(exec, args, 'text', false, true, function(ev) { + out.textContent = ev.target.response; + }).then(function(res) { + out.textContent = res; }).catch(function(err) { ui.addNotification(null, E('p', [ err ])) }).finally(function() { -- 2.30.2